//
//  AboutUSViewController.m
//  SmartCoin
//
//  Created by apple on 2018/3/23.
//  Copyright © 2018年 Cynic. All rights reserved.
//

#import "AboutUSViewController.h"
#import "Rules/RuleViewController.h"
#import <WebKit/WebKit.h>
@interface AboutUSViewController ()

@end

@implementation AboutUSViewController

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    if (cx_hit == 812) {
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    }
    else{
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    };
}

-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    if (cx_hit == 812) {
        
    }
    else{
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self viewLoad];
}



-(void)viewLoad{
    self.view.backgroundColor = bggrayColor;
    [self setNavigationViewWithTitle:@"关于我们" WithCanPop:YES WithPopData:@"black_return" WithPopisString:NO WithHasRightOperation:NO WithrightOperationData:@"" WithRightisString:NO WithNavigationColor:[UIColor clearColor] withBgView:self.view];
    self.centerTitle.textColor = [UIColor blackColor];
//    [self partLoad];
    [self webLoad];
}

-(void)webLoad{
    WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 44 + cxsingler.topdis, cx_wid, cx_hit - cxsingler.bottomdis - cxsingler.topdis - 44 )];
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:aboutusurl]]];
    [self.view addSubview:webView];
}

-(void)partLoad{
    UIImageView *logoView = [[UIImageView alloc] init];
    logoView.bounds = CGRectMake(0, 0, cx_wid / 5, cx_wid / 5);
    logoView.center = CGPointMake(cx_wid / 2, cx_hit / 2);
    logoView.image = [UIImage imageNamed:@"logo1"];
    //    logoView.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.3];
    [self.view addSubview:logoView];
    
    UILabel *namelabel = [[UILabel alloc] init];
    namelabel.text = @"智积分";
    namelabel.bounds = CGRectMake(0, 0, cx_wid, 20);
    namelabel.center = CGPointMake(cx_wid / 2, cx_hit / 2 + cx_wid / 10 + 30);
    namelabel.font = [UIFont systemFontOfSize:18];
    namelabel.textAlignment = NSTextAlignmentCenter;
    namelabel.textColor = [UIColor blackColor];
    [self.view addSubview:namelabel];
    
    [self segload];
}

-(void)segload{
    NSArray *titles = @[@"官方网站",@"服务条款"];
    for (NSInteger index = 0; index < 2; index ++) {
        UIButton *seg = [[UIButton alloc]initWithFrame:CGRectMake(cx_wid / 2 - 100 + 110 * index, cx_hit - cxsingler.bottomdis - 70, 90, 30)];
        [seg addTarget:self action:@selector(segtaped:) forControlEvents:UIControlEventTouchUpInside];
        [seg setTitle:titles[index] forState:UIControlStateNormal];
        [seg setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        seg.titleLabel.font = [UIFont systemFontOfSize:16];
        if (index == 0) {
            seg.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        }
        else if (index == 1){
            seg.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        }
        [self.view addSubview:seg];
    }
    UIView *layerView = [[UIView alloc] initWithFrame:CGRectMake(cx_wid / 2 - 0.5, cx_hit - cxsingler.bottomdis - 70, 1,30 )];
    layerView.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:layerView];
    
    UILabel *companyLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, cx_hit - cxsingler.bottomdis - 30, cx_wid, 18)];
    companyLabel.text = @"成都市米茶网络有限公司 版权所有";
    companyLabel.textAlignment = NSTextAlignmentCenter;
    companyLabel.textColor = [UIColor blackColor];
    companyLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:companyLabel];
}

-(void)segtaped:(UIButton *)sender{
    NSString *title = sender.titleLabel.text;
    if ([title isEqual:@"官方网站"]) {
        
    }
    else if ([title isEqual:@"服务条款"]){
        RuleViewController *nextVC = [[RuleViewController alloc] init];
        [self.navigationController pushViewController:nextVC animated:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
